﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="xml" indent="yes" encoding="utf-8" media-type="text/xml" />
  <xsl:include href="../Utility.xslt"/>
  <xsl:param name="relrootpath"/>
  <xsl:param name="eventname" />
  <xsl:param name="userid" />
  <xsl:param name="lastupdate" />

  <xsl:template match="/Context">
    <Transform>
      <Content>
        <div class="datetext">
          <xsl:value-of select="$lastupdate"/>
        </div>
        <xsl:apply-templates select="Events[@EventName=$eventname]">
        </xsl:apply-templates>
      </Content>
    </Transform>
  </xsl:template>

  <xsl:template match="Events[@EventName='GroupRoleChanged']">
    <div>
      <dl>
        <dt>
          <xsl:call-template name="IconSet">
            <xsl:with-param name="c">ns-info</xsl:with-param>
          </xsl:call-template>
          <span class="iconlabel">
            <control kind="userlink">
              <xsl:attribute name="UserId">
                <xsl:value-of select="$userid"/>
              </xsl:attribute>
            </control>
            <xsl:text>现在是</xsl:text>
            <strong>
            <xsl:value-of select="Event/NewRole"/>
            </strong>
          </span>
          
        </dt>
      </dl>
    </div>
  </xsl:template>

  <xsl:template match="Events[@EventName='ThreadCreated']">
    <div>
      <dl>
        <dt>
          <xsl:call-template name="IconSet">
            <xsl:with-param name="c">ns-reply</xsl:with-param>
          </xsl:call-template>
          <span class="iconlabel">
            <control kind="userlink">
              <xsl:attribute name="UserId">
                <xsl:value-of select="$userid"/>
              </xsl:attribute>
            </control>
            <xsl:text>发表了新话题：</xsl:text>
          </span>
          <xsl:apply-templates select="Event" mode="ThreadCreated"/>
        </dt>
      </dl>
    </div>
  </xsl:template>

  <xsl:template match="Event" mode="ThreadCreated">
    <dd>
      <a>
        <xsl:attribute name="href">
          <xsl:value-of select="$relrootpath"/>
          <xsl:text>/Mod/Groups/Posts/Posts.aspx?u=1&amp;t=</xsl:text>
          <xsl:value-of select="ThreadId"/>
          <xsl:text>&amp;id=</xsl:text>
          <xsl:value-of select="GroupId"/>
        </xsl:attribute>
        <xsl:value-of select="Title" />
      </a>
    </dd>
  </xsl:template>

  <xsl:template match="Events[@EventName='NewMember']">
    <dl>
      <xsl:apply-templates select="Event" mode="NewMember" />
    </dl>
  </xsl:template>

  <xsl:template match="Events/Event" mode="NewMember">
    <dt>
      <xsl:call-template name="IconSet">
        <xsl:with-param name="c">ns-info</xsl:with-param>
      </xsl:call-template>
      <span class="iconlabel">
        <control kind="userlink">
          <xsl:attribute name="UserId">
            <xsl:value-of select="UserId"/>
          </xsl:attribute>
        </control>
        <xsl:text>加入了圈子。</xsl:text>
      </span>
    </dt>

  </xsl:template>

  <xsl:template match="Events[@EventName='NewGroup']">
    <dl>
      <dt>
        <xsl:call-template name="IconSet">
          <xsl:with-param name="c">ns-group</xsl:with-param>
        </xsl:call-template>
        <span class="iconlabel">
          <control kind="userlink">
            <xsl:attribute name="UserId">
              <xsl:value-of select="$userid"/>
            </xsl:attribute>
          </control>
          <xsl:text>组建了圈子：</xsl:text>
        </span>
      </dt>
      <xsl:apply-templates select="Event" mode="NewGroup" />
    </dl>
  </xsl:template>

  <xsl:template match="Events/Event" mode="NewGroup">
    <dd>
      <xsl:call-template name="GroupLink">
        <xsl:with-param name="gid" select="GroupId" />
        <xsl:with-param name="gname" select="GroupName" />
        <xsl:with-param name="rp" select="$relrootpath" />
      </xsl:call-template>
      <span class="litetext">
        [<xsl:value-of select="GroupCategory"/>]
      </span>。
    </dd>

  </xsl:template>


</xsl:stylesheet>
